{include header}
<h3 class="h3">{$thread_data.title}</h3>
{hook t_thread_index_1}
<table class="t-item" tid="{$thread_data.id}" summary="forum_all" cellspacing="0" cellpadding="0">
    <thead>
        <tr class="pll" id="thread">
            <td style="vertical-align: top;">
                <img style="vertical-align: middle;" width="50" height="50" class="ty" src="{#WWW}{$thread_data.avatar.b}">
                {if IS_LOGIN }
					{if $thread_data['uid'] == $user['id'] || $user['group'] == C("ADMIN_GROUP")}
                    <a class="t-user label label-danger" href="{#WWW}/post/edit/id/{$post_data.id}.html" style="    line-height: 30px;">编辑</a>
					{/if}
                {/if}
            </td>
            <td class="t-info">
                <a class="t-user label label-success" href="#">{$thread_data.user}</a>
                {if IS_LOGIN }
                {if $thread_data['uid'] == $user['id'] || $user['group'] == C("ADMIN_GROUP")}
                <a class="t-user label label-danger" onclick="del_thread({$thread_data.id},'thread')" >删除主题</a>
                {/if}
                {if $user['group'] == C("ADMIN_GROUP")}
                    {if $thread_data['top'] == 1}
                    <a class="t-user label label-danger" onclick="thread_top({$thread_data.id},'off',1)" >取消板块置顶</a>
                    {else}
                    <a class="t-user label label-success" onclick="thread_top({$thread_data.id},'on',1)" >板块置顶</a>
                    {/if}
                {/if}
                {/if}
                {if $user['group'] == C("ADMIN_GROUP")}
                    {if $thread_data['top'] == 2}
                    <a class="t-user label label-danger" onclick="thread_top({$thread_data.id},'off',2)" >取消全站置顶</a>
                    {else}
                    <a class="t-user label label-success" onclick="thread_top({$thread_data.id},'on',2)" >全站置顶</a>
                    {/if}
                {/if}
                {hook t_thread_index_user}
                <div class="editor-style"  style="    margin-top: 18px;">
                    <p>
                        {$post_data.content}
                        {hook t_thread_index_2}
                    </p>
                </div>
                <p class="l item-info">
                    <?php echo $forum[$thread_data['fid']]['name']; ?> &nbsp;•&nbsp; <?php echo humandate($thread_data['atime']); ?> &nbsp;•&nbsp;
                    <i class="fa fa-comment-o"></i> {$thread_data.posts} &nbsp;•&nbsp;
                    <a {if $thread_data['goods']>C("UP_SIZE")} style="color:<?php echo C("UP_RGB"); ?>" {/if} href="javascript:void(0);" onclick="tp('thread1',{$thread_data.id},this)">
                        <i class="fa fa-thumbs-o-up"></i>
                        <span>{$thread_data.goods}</span>
                    </a> &nbsp;•&nbsp;
                    <a {if $thread_data['nos']>C("DOWN_SIZE")} style="color:<?php echo C("DOWN_RGB"); ?>" {/if} href="javascript:void(0);" onclick="tp('thread2',{$thread_data.id},this)">
                        <i class="fa fa-thumbs-o-down"></i>
                        <span>{$thread_data.nos}</span>
                    </a> &nbsp;•&nbsp;
                     <i class="fa fa-eye"></i> {$thread_data.views}
                     {hook t_thread_index_3}
                </p>


            </td>
        </tr>
    </thead>
    <tbody id="postlist">
        {foreach $PostList as $v}
        {hook t_thread_index_4}
        <tr class="pll">
        	<td class="t-post">
        		<img width="50" height="50" class="ty" src="{#WWW}{$v.avatar.b}">
                {if IS_LOGIN }
					{if $v['uid'] == $user['id'] || $user['group'] == C("ADMIN_GROUP")}
                    <a class="t-user label label-danger" href="{#WWW}/post/edit/id/{$v.id}.html" style="    line-height: 30px;">编辑</a>
					{/if}
                {/if}
        	</td>
        	<td class="t-info t-post">
        		<a class="t-user label label-success" href="#">{$v.user}</a>
                {if IS_LOGIN }
                {if $v['uid'] == $user['id'] || $user['group'] == C("ADMIN_GROUP")}
                <a class="t-user label label-danger" onclick="del_thread({$v.id},'post')" >删除帖子</a>
                {/if}
                {/if}
                {hook t_thread_index_user2}

        		<div class="editor-style" style="    margin-top: 18px;">
        			{$v.content}
                    {hook t_thread_index_5}
        		</div>
        		<p class="l item-info">
                    {hook t_thread_index_6}
        		#{$v.key} &nbsp;•&nbsp; {$v.atime_str} &nbsp;•&nbsp;
                <a {if $v['goods']>C("UP_SIZE")} style="color:<?php echo C("UP_RGB"); ?>" {/if} href="javascript:void(0);" onclick="tp('post1',{$v.id},this)">
                    <i class="fa fa-thumbs-o-up"></i> <span>{$v.goods}</span>
                </a> &nbsp;•&nbsp;
                <a {if $v['nos']>C("DOWN_SIZE")} style="color:<?php echo C("DOWN_RGB"); ?>" {/if} href="javascript:void(0);" onclick="tp('post2',{$v.id},this)">
                    <i class="fa fa-thumbs-o-down"></i> <span>{$v.nos}</span>
                </a> &nbsp;•&nbsp;
                <a href="javascript:void(0);" onclick="editor.setValue(editor.getValue()+'@{$v.user}');$('.c-left').scrollTop( $('.c-left')[0].scrollHeight );">回复</a>
                {hook t_thread_index_7}
        		</p>

        	</td>
        </tr>
        {/foreach}
        <tr>
        	<td></td>
        	<td>
        		<nav style="    margin-bottom: 56px;">
        		  <ul class="pager" style="margin: 10px 0;">
        		    <li class="previous {if $pageid==1}disabled{/if}"><a href="{if $pageid==1}javascript:void(0);{else}{#WWW}/thread/{$thread_data.id}.html?pageid={$pageid-1}{/if}" >previous</a></li>
        		    <li class="next {if $pageid==$page_count}disabled{/if}"><a href="{if $pageid==$page_count}javascript:void(0);{else}{#WWW}/thread/{$thread_data.id}.html?pageid={$pageid+1}{/if}" >Next</a></li>
        		  </ul>
        		</nav>
        	</td>
        </tr>
    </tbody>
    <tfoot>
        <tr>
			<td class="t-post">
				<img style="vertical-align: middle;" width="50" height="50" class="ty" src="{if !IS_LOGIN}/public/images/user.gif{else}{$user.avatar.b}{/if}">
			</td>
			<td class="t-info t-post">
                    <link href="/public/css/simditor.css" type="text/css" rel="stylesheet">
				{if IS_LOGIN}
                    {hook t_thread_index_8}
					<a class="t-user label label-success" href="#" style="padding-bottum">{$user.user}</a> <span class="item-info">回复主题 : 主题标题</span>
					<textarea id="editor" autofocus></textarea>
					<button id="post" class="btn btn-primary">发表评论</button>
                    {hook t_thread_index_9}
                    <script src="/public/js/edit.min.js"></script>
                    <script>

                        $(function(){
                            $("#post").click(function(){
                                var forum = $("#forum").val();
                                $.ajax({
                                 url: '/post/post.html',
                                 type:"POST",
                                 cache: false,
                                 data:{
                                     id:{$thread_data.id},
                                     content:editor.textarea.val(),
                                     {hook t_thread_index_10}
                                 },
                                 dataType: 'json'
                             }).then(function(e) {
                                 {hook t_thread_index_11}
                                 if(!e.error)
                                    alert(e.info);
                                else
                                    window.location.reload();

                               }, function() {
                                   {hook t_thread_index_12}
                                 alert('请尝试重新提交');
                               });
                            })
                        })
                    </script>
				{else}
				<div style="width: 100%;background-color:#F7F7F7;padding: 55px 0;">
                    {hook t_thread_index_13}
					<div style="    color: teal;text-align: center;">您需要登录后才可以回帖 <a href="/user/login.html" style="color: blue;">登录</a><small>|</small><a href="/user/add.html" style="color: blue;">立即注册</a></div>
				</div>
				{/if}
			</td>
		</tr>
    </tfoot>


</table>
<style>
.simditor {
margin-top: 10px;
}
</style>
{include footer}
